﻿@using Orchard.ContentManagement;

@{
    var userCanRegister = @WorkContext.CurrentSite.As<Orchard.Users.Models.RegistrationSettingsPart>().UsersCanRegister;
    var enableLostPassword = @WorkContext.CurrentSite.As<Orchard.Users.Models.RegistrationSettingsPart>().EnableLostPassword;
}

<h1 class="page-title">@Html.TitleForPage((string)Model.Title)</h1>
<p>
    @T("Please enter your username and password.") 
    @if(userCanRegister) { @Html.ActionLink(T("Register").Text, "Register") @T(" if you don't have an account.") }
    @if(enableLostPassword) { @Html.ActionLink(T("Lost your Password?").Text, "RequestLostPassword") }
</p>

@{
    var errors = ViewContext.ViewData.ModelState.Where(x => x.Value.Errors.Count > 0).SelectMany(x => x.Value.Errors);
}
@foreach (var error in errors) {
    <div class="alert alert-error">
        <a class="close" data-dismiss="alert">×</a>
        <div class="alert-heading"><h4>Error</h4></div>
        <strong>@(error.ErrorMessage)</strong>
    </div>
}

@using (Html.BeginFormAntiForgeryPost(Url.Action("LogOn", new { ReturnUrl = Request.QueryString["ReturnUrl"] }))) {
<fieldset class="form-horizontal">
    <legend>@T("Account Information")</legend>
    <div class="control-group">
        <label class="control-label" for="username-email">@T("Username")</label>
        <div class="controls">
            @Html.TextBox("userNameOrEmail", "", new { id = "username-email", autofocus = "autofocus" })
            @Html.ValidationMessage("userNameOrEmail", new { @class = "help-inline"})
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="password">@T("Password")</label>
        <div class="controls">
            @Html.Password("password")
            @Html.ValidationMessage("password", new { @class = "help-inline"})    
        </div>
    </div>
    <div class="form-actions">
        <button class="btn btn-primary" type="submit">@T("Sign In")</button>
    </div>
</fieldset>
}